package com.jerry.template.views;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jerry.template.R;

/**
 * Created by chenhuan on 2016/5/11.
 */
public class MsgItemView extends LinearLayout{

    private ImageView imageView = null;
    private TextView title = null;


    public MsgItemView(Context context){
        this(context, null);
    }

    public MsgItemView(Context context, AttributeSet attrs){
        super(context, attrs);
        LayoutInflater inflater = LayoutInflater.from(context);
        inflater.inflate(R.layout.select_item_layout, this);
        imageView = (ImageView) findViewById(R.id.iv_item);
        title = (TextView) findViewById(R.id.tv_tip);
        initAttribute(context, attrs);
    }

    private void initAttribute(Context context, AttributeSet attrs){
        TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.HotelSelect);

        Drawable icon = array.getDrawable(R.styleable.HotelSelect_hotel_icon);
        imageView.setImageDrawable(icon);

        String title = array.getString(R.styleable.HotelSelect_hotel_title);
        this.title.setText(title);
        array.recycle();
    }


}
